﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DreamBox.Net.Core
{
    public static class ID
    {
        /// <summary>
        /// 获取新的GUID
        /// </summary>
        /// <returns></returns>
        public static string GetGUID()
        {
            return System.Guid.NewGuid().ToString().ToUpper().Replace("-", "");
        }
        /// <summary>
        /// 根据不同的前缀获取一个编号
        /// </summary>
        /// <param name="Prefix"></param>
        /// <returns></returns>
        public static string GetID(string Prefix)
        {
            return Prefix + DateTime.Now.ToString("yyyyMMddhhmmssffff");
        }
        /// <summary>
        /// 获取ID
        /// </summary>
        /// <returns></returns>
        public static int GetID()
        {
            DateTime date = DateTime.Now;
            int year = (date.Year - 2014) == 0 ? 1 : date.Year - 2014;
            string mon = date.ToString("MM");
            string dd = date.ToString("dd");
            string hh = date.ToString("HH");
            string mi = date.ToString("mm");
            string ss = date.ToString("ss"); 
            string ms = date.ToString("ffff");

            int d = int.Parse(mon + dd + hh + mi) + int.Parse(mi + ss + ms);
            d = int.Parse("1" + d);
            return d;
        }
    }
}
